<?php
defined('IN_IA') or exit('Access Denied');
global $_GPC, $_W;
$uniacid = $_W['uniacid'];
$itemid = $_GPC['itemid'];
$itemtitle = $_GPC['itemtitle'];
$itemmsell = $_GPC['itemmsell'];
$itempic = $_GPC['itempic'];
$itemfee = $_GPC['itemfee'];
$itemfee2 = $_GPC['itemfee2'];
$itemfee3 = $_GPC['itemfee3'];
$do = $_GPC['act'];
$openid = $_GPC['openid'];
if (empty($openid)) {
	exit(json_encode(array('status' => 500)));
}
$table = "table" . $do;
$table = "tablefav";
$fav = pdo_fetch("SELECT * FROM " . tablename($this->$table) . " WHERE uniacid = '{$uniacid} ' AND itemid = '{$itemid}' AND openid = '{$openid}' ");
if (empty($fav) && $_W['isajax']) {
	$data = array('uniacid' => $uniacid, 'openid' => $openid, 'itemid' => $itemid, 'itemtitle' => $itemtitle, 'itempic' => $itempic, 'itemmsell' => $itemmsell, 'itemfee' => $itemfee, 'itemfee2' => $itemfee2, 'itemfee3' => $itemfee3, 'ctime' => TIMESTAMP,);
	pdo_insert($this->$table, $data);
	exit(json_encode(array('status' => 1)));
} else {
	pdo_delete($this->$table, array('id' => $fav['id']));
	exit(json_encode(array('status' => 0)));
}